package com.friend.joey.applicationfriend.Classes;

import java.util.Calendar;

/**
 * Created by Joey on 2017/4/26.
 */

public class TimeDeal {
    //Calendar ctime;//系统时间
    public static final int INITDATE=0;
    public static final int GETDATE=1;
    public static final int GETTIME=2;
    int year;
    int month;
    int day;
    int first;
    int last;
    int hour;
    int min;
    int second;
    public TimeDeal(int year,int month,int day){
        this.year=year;
        this.month=month;
        this.day=day;
    }
    public TimeDeal(int type){
        if(type==INITDATE){  //初始化为当前时间
            GetCurrentTime();
        }
    }
    public TimeDeal(int year,int month,int day,int hour,int minute){
        this.year=year;
        this.month=month;
        this.day=day;
        this.hour=hour;
        this.min=minute;
    }
    public TimeDeal(){

    }
    //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS");
    //String time = format.format(ctime.getTime());
    //获取当前时间函数
    public void GetCurrentTime() {
        Calendar ctime;
        ctime = Calendar.getInstance();
        year = ctime.get(Calendar.YEAR);//获取年
        month = ctime.get(Calendar.MONTH) + 1;//获取月份，0表示1月份
        day = ctime.get(Calendar.DAY_OF_MONTH);//获取当前天数
        first = ctime.getActualMinimum(ctime.DAY_OF_MONTH);//获取本月最小天数
        last = ctime.getActualMaximum(ctime.DAY_OF_MONTH);//获取本月最大天数
        hour = ctime.get(Calendar.HOUR_OF_DAY);//获取当前小时
        min = ctime.get(Calendar.MINUTE);//获取当前分钟
        second = ctime.get(Calendar.SECOND);//获取当前秒
    }
    public long GetTime(){
        Calendar ctime;
        ctime = Calendar.getInstance();
        ctime.set(Calendar.YEAR,year);
        ctime.set(Calendar.MONTH,month-1);
        ctime.set(Calendar.HOUR_OF_DAY,hour);
        ctime.set(Calendar.MINUTE,min);
        return ctime.getTimeInMillis();
    }
    public String GetDateString(){
        String cyear;
        String cmonth;
        String cday;
        cyear=String.valueOf(year);
        cmonth=String.valueOf(month);
        cday=String.valueOf(day);
        String time=cyear+"/"+cmonth+"/"+cday;
        return time;
    }
    public String GetDayTimeString(){
        return "";
    }
    public String GetTimeString(){
        String chour;
        String cmin;
        if(hour<10){
            chour="0"+String.valueOf(hour);
        }else{
            chour=String.valueOf(hour);
        }
        if(min<10){
            cmin="0"+String.valueOf(min);
        }else{
            cmin=String.valueOf(min);
        }
        String time=chour+":"+cmin;
        return time;
    }
    public String GetAlertTimeString(){
        String chour;
        String cmin;
        if(hour<10){
            chour="0"+String.valueOf(hour);
        }else{
            chour=String.valueOf(hour);
        }
        if(min<10){
            cmin="0"+String.valueOf(min);
        }else{
            cmin=String.valueOf(min);
        }
        String time=String.valueOf(year)+"/"+String.valueOf(month)+"/"+String.valueOf(day)+" "+chour+":"+cmin;
        return time;
    }
    private String getWeekDay(){
        return"周一";
    }
    private boolean isToday(){
        return false;
    }
    public int getYear(){
        return year;
    }
    public int getMonth(){
        return month;
    }
    public int getDay(){
        return day;
    }
    public int getHour(){
        return hour;
    }
    public int getMinB(){
        return min+1;
    }
    public int getMin(){
        return min;
    }

    public boolean isAlertAbled(){
        long a=GetTime();
        long b=System.currentTimeMillis();
        return a>b;
    }
}
